<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('失效公司')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>


</head>
<body class="gray-bg">
<form id="user-form">
    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <div class="select-list">
                        <ul>
                            <li>
                                公司编码：<input type="text" name="compCode" id="compCode"/>
                            </li>
                            <li>
                                公司名称：<input type="text" id="title" name="title"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>

                            </li>
                        </ul>
                    </div>
                </div>

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="selectCompany()">
                        <i class="fa fa-plus"></i> 添加公司
                    </a>
                    <a class="btn btn-primary" onclick="edit()">
                        <i class="fa fa-edit"></i> 批量设置失效日期
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    &nbsp;&nbsp;&nbsp;
                    <a class="btn btn-primary" onclick="Confirmation()">确认检查</a>
                    <a class="btn btn-warning" onclick="CancelConfirmation()">取消确认</a>
                    <a class="btn btn-success" onclick="Implement()">执行失效</a>

                </div>

                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table" data-mobile-responsive="true"></table>
                </div>
            </div>
        </div>
    </div>
</form>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>


<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('jinpeng:company:edit')}]];
    var detailFlag = [[${@permission.hasPermi('jinpeng:company:detail')}]];

    var prefix = ctx + "company/admin";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryCompanyList();
    });

    function queryCompanyList() {
        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/list?type=3",
            removeUrl: prefix + "/remove",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "公司",
            columns: [{
                checkbox: true
            }, {
                field: 'compCode',
                title: '公司代码'
            },
                {
                    field: 'title',
                    title: '公司名称'
                },
                {
                    field: 'compAbbr',
                    title: '*公司简称'
                },
                {
                    field: 'compGradeName',
                    title: '公司级别'
                },
                {
                    field: 'compTypeName',
                    title: '公司类型'
                },
                {
                    field: 'industuName',
                    title: '所属行业'
                },
                {
                    field: 'compAreaName',
                    title: '公司区域'
                },
                {
                    field: 'adminName',
                    title: '上级公司'
                },
                {
                    field: 'lawyer',
                    title: '法人代表'
                },
                {
                    field: 'address',
                    title: '公司地址'
                },
                {
                    field: 'regAddress',
                    title: '注册地址'
                },
                {
                    field: 'tel',
                    title: '联系电话'
                },
                {
                    field: 'postCode',
                    title: '邮政编码'
                },
                {
                    field: 'webSite',
                    title: '公司网站'
                },
                {
                    field: 'socialCreCode',
                    title: '统一社会信用代码'
                },
                {
                    field: 'enterpriseQuafic',
                    title: '企业资质'
                },
                {
                    field: 'companyProfile',
                    title: '公司简介'
                },
                {
                    field: 'effectDate',
                    title: '*失效日期'
                },
                {
                    field: 'xorder',
                    title: '排序'
                }, {
                    field: 'remark',
                    title: '备注'
                }, {
                    field: 'regByName',
                    title: '登记人'
                }, {
                    field: 'regDate',
                    title: '登记时间'
                }, {
                    field: 'initializedBy',
                    title: '确认人'
                }, {
                    field: 'initializedTime',
                    title: '确认时间'
                }]
        };
        $.table.init(options);
    }

    function selectCompany() {
        $.operate.eject_window("添加公司(有效)", ctx + "company/admin/selectCompany?type=3", "xiao");

    }

    function Confirmation() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请选择要确认检查的数据");
            return;
        }
        var allId = getAllId(row);
        $.ajax({
            async: false,
            url: "/company/admin/ProcedureRegister?type=3&procedure=oSP_CompCheck&ids=" + allId,
            data: {},
            type: "post",
            dataType: "text",
            success: function (data) {
                if (data != "") {
                    alert(data);
                } else {
                    $.modal.alertSuccess('确认检查成功');
                }
                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    function CancelConfirmation() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请选择要取消确认的数据");
            return;
        }
        var allId = getAllId(row);
        $.ajax({
            async: false,
            url: "/company/admin/ProcedureRegister?type=3&procedure=oSP_CompCancel&ids=" + allId,
            data: {},
            type: "post",
            dataType: "text",
            success: function (data) {
                if (data != "") {
                    alert(data);
                } else {
                    $.modal.alertSuccess('取消确认成功');
                }
                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    function Implement() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请选择要执行失效的数据");
            return;
        }
        var allId = getAllId(row);
        $.ajax({
            async: false,
            url: "/company/admin/ProcedureRegister?type=3&procedure=oSP_CompStart&ids=" + allId,
            data: {},
            type: "post",
            dataType: "text",
            success: function (data) {
                if (data != "") {
                    alert(data);
                } else {
                    $.modal.alertSuccess('执行失效成功');
                }
                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    function edit() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请选择要设置失效日期的数据");
            return;
        }
        var allId = getAllId(row);
        $.operate.edit_currency("设置", '失效日期', allId, "公司", "/company/admin/expirationDate", "xiao");
    }

    function getAllId(row) {
        var allId = "";
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        return allId;
    }
</script>
</body>
</html>